<?php
/**
 * Created by PhpStorm.
 * User: Romolo
 * Date: 2020/5/29
 * Time: 22:43
 */

require __DIR__.'/../../src/Blocking/Worker.php';

use Romolo\Snitso\Blocking\Worker;

$worker = new Worker('tcp://0.0.0.0:8000');

$worker->onConnect = function ($worker, $client) {
    echo '有一个连接进来了' . PHP_EOL;
};

$worker->onReceive = function (Worker $worker, $client, $data) {
    var_dump($data . PHP_EOL);
    $worker->send($client, 'Hello client');
};

$worker->start();